package com.ruoyi.web.controller.ring;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.ring.domain.RingTrainingInfo;
import com.ruoyi.ring.service.IRingTrainingInfoService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 训练详细Controller
 * 
 * @author liuwp
 * @date 2025-08-18
 */
@RestController
@RequestMapping("/ring/ring_training_info")
public class RingTrainingInfoController extends BaseController
{
    @Autowired
    private IRingTrainingInfoService ringTrainingInfoService;

    /**
     * 查询训练详细列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_training_info:list')")
    @GetMapping("/list")
    public TableDataInfo list(RingTrainingInfo ringTrainingInfo)
    {
        startPage();
        List<RingTrainingInfo> list = ringTrainingInfoService.selectRingTrainingInfoList(ringTrainingInfo);
        return getDataTable(list);
    }

    /**
     * 导出训练详细列表
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_training_info:export')")
    @Log(title = "训练详细", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, RingTrainingInfo ringTrainingInfo)
    {
        List<RingTrainingInfo> list = ringTrainingInfoService.selectRingTrainingInfoList(ringTrainingInfo);
        ExcelUtil<RingTrainingInfo> util = new ExcelUtil<RingTrainingInfo>(RingTrainingInfo.class);
        util.exportExcel(response, list, "训练详细数据");
    }

    /**
     * 获取训练详细详细信息
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_training_info:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(ringTrainingInfoService.selectRingTrainingInfoById(id));
    }

    /**
     * 新增训练详细
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_training_info:add')")
    @Log(title = "训练详细", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody RingTrainingInfo ringTrainingInfo)
    {
        return toAjax(ringTrainingInfoService.insertRingTrainingInfo(ringTrainingInfo));
    }

    /**
     * 修改训练详细
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_training_info:edit')")
    @Log(title = "训练详细", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody RingTrainingInfo ringTrainingInfo)
    {
        return toAjax(ringTrainingInfoService.updateRingTrainingInfo(ringTrainingInfo));
    }

    /**
     * 删除训练详细
     */
    @PreAuthorize("@ss.hasPermi('ring:ring_training_info:remove')")
    @Log(title = "训练详细", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(ringTrainingInfoService.deleteRingTrainingInfoByIds(ids));
    }
}
